package cluster.traversal;

import text.Text;
import text.traversal.ITextTraversal;

public class ComputeIDF implements ITextTraversal
{
	public final static String IDF = "IDF";
	
	private final int textCount;
	
	public void traversal(String word, Text text)
	{
		Double referenceCount = text.getInfo(ComputeWordReferenceCount.WORD_REFERENCE_COUNT, word);
		
		double idf = Math.log10((double)textCount / referenceCount);
		
		text.addInfo(IDF, word, idf);
	}
	
	public ComputeIDF(int textCount)
	{
		this.textCount = textCount;
	}
}
